class Recommand < ActiveRecord::Base
  attr_accessible :recommander_id, :terminal_id, :user_id
  belongs_to :recommander, class_name: 'Account', counter_cache: :recommand_count
  belongs_to :terminal
  validates_uniqueness_of :user_id

  # Todo(@Thomson->@Thomson): we should double check the time stuff, because the timezone may be mixed
  scope :after_date, lambda {|date| where(["recommands.created_at >= ?", date])}
  scope :before_date, lambda {|date| where(["recommands.created_at < ?", 1.days.since(Time.zone.parse(date)).strftime("%Y-%m-%d")])}

end
